package zdream.pmfield.test.stage.battle;

import org.junit.Before;
import org.junit.Test;

import zdream.pmfield.data.foe.Foe;
import zdream.pmfield.data.foe.MoveTemplate;
import zdream.pmfield.stage.StageBuilderForTest;
import zdream.pmfield.stage.StageWrapper;
import zdream.pmfield.stage.object.FoeActor;
import zdream.pmfield.storage.FoeTemplateStorage;
import zdream.pmfield.test.utils.ResourceConstant;

import static org.junit.Assert.*;

/**
 * @author Zdream
 * @date 2023-11-29
 * @since 0.0.1
 */
public class Normal1v1BattleCase {
	FoeTemplateStorage storage;

	@Before
	public void before() {
		storage = new FoeTemplateStorage();
		storage.load();
		storage.loadMovesInResource(ResourceConstant.RES_PATH_TEST_MOVES_JSON);
	}

	@Test
	public void testNormalBattle() {
		MoveTemplate move1 = storage.findMoveById(10000010, 1);

		Foe foe1 = Foe.builder(storage.findFoeById(4))
				.withLevel(20)
				.withMove(move1)
				.build();
		Foe foe2 = Foe.builder(storage.findFoeById(1))
				.withLevel(20)
				.withMove(move1)
				.build();

		final StageWrapper wrapper = StageBuilderForTest.builder()
				.putFoeToOneSide(foe1)
				.putFoeToAnotherSide(foe2)
				.withStorage(storage)
				.buildWrapper();
		for (FoeActor allFoe : wrapper.stage.allFoes) {
			assertFalse(allFoe.attackMoves.isEmpty());
			assertFalse(allFoe.stageMoves.isEmpty());
			assertTrue(allFoe.stageMoves.stream().anyMatch(move -> "跳过回合".equals(move.move.name)));
			assertTrue(allFoe.stageMoves.stream().anyMatch(move -> "移动".equals(move.move.name)));
		}
	}
}
